﻿using AppFramework;
using AppFramework.Authorization.Users.Profile.Dto;
using AppFramework.Demo.Dtos;
using AppFramework.DinosaursParkMes.Material;
using AppFramework.DinosaursParkMes.Production;
using AppFramework.DinosaursParkMes.Production.DTO;
using AppFramework.Shared;
using AppFramework.Shared.Models;
using Models.DinosaursParkMes.Production;
using Prism.Commands;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ViewModels.DinosaursParkMes.Production
{
    public class MaterialViewModel : HostDialogViewModel
    {
        private readonly IMaterialRequisitionService appService;
        private readonly MaterialRequisitionService service;
        public MaterialRequisition material;
        public MaterialRequisitionDTO materialDTO;
        private GetPasswordComplexitySettingOutput settingOutput;

        /// <summary>
        /// 构造函数进行依赖注入
        /// </summary>
        /// <param name="appService"></param>
        /// <param name="material"></param>
        /// <param name="materialDTO"></param>
        /// <param name="service"></param>
        public MaterialViewModel(IMaterialRequisitionService appService, MaterialRequisition material = null, MaterialRequisitionDTO materialDTO = null, MaterialRequisitionService service = null)
        {
            this.appService = appService;
            this.material = material;
            this.materialDTO = materialDTO;
            //MaterialAdd = new DelegateCommand<MaterialRequisitionDTO>(service.PostMaterAdd(materialDTO));
            this.service = service;

        }

        public MaterialRequisition Models
        {
            get { return material; }
            set { material = value; OnPropertyChanged(); }
        }
        /// <summary>
        /// 重写添加
        /// </summary>
        /// <returns></returns>
        public override async Task Save()
        {
            await SetBusyAsync(async () =>
            {
                var dto = Map<MaterialRequisitionDTO>(Models);
                await WebRequest.Execute(async () =>
                {
                    await appService.PostMaterAdd(dto);
                },base.Save);
            });
        }
          
       // public DelegateCommand MaterialAdd { get; private set; }

        public override void OnDialogOpened(IDialogParameters parameters)
        {
            throw new NotImplementedException();
        }
    }
}
